// 导入 axios
import axios from '@/utils/request.js'
// import store from '@/store/index.js'

// export default 123

// 1.获取频道文章数据---------------------------------
export const getArticles = (channelId, timestamp) => {
  return axios({
    method: 'get',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp,
      with_top: 1
    }
  })
}

// 2.获取文章详情---------------------------------
export const getArticleById = (aid) => {
  return axios({
    method: 'get',
    url: `/v1_0/articles/${aid}`
  })
}

// 3.对作者添加关注---------------------------------
export const addFollow = (usrId) => {
  return axios({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target: usrId
    }
  })
}

// 4.对作者取消关注---------------------------------
export const unFollow = (usrId) => {
  return axios({
    method: 'DELETE',
    url: `/v1_0/user/followings/${usrId}`
  })
}

// 5.收藏文章---------------------------------
export const addCollect = (articleId) => {
  return axios({
    method: 'post',
    url: '/v1_0/article/collections',
    data: {
      target: articleId
    }
  })
}

// 6.取消收藏文章---------------------------------
export const deleteCollect = (articleId) => {
  return axios({
    method: 'DELETE',
    url: `/v1_0/article/collections/${articleId}`
  })
}

// 7.点赞文章---------------------------------
export const addLike = (articleId) => {
  return axios({
    method: 'post',
    url: '/v1_0/article/likings',
    data: {
      target: articleId
    }
  })
}

// 8.取消点赞文章---------------------------------
export const deleteLike = (articleId) => {
  return axios({
    method: 'DELETE',
    url: `/v1_0/article/likings/${articleId}`
  })
}
